// 控制台相关类型定义

// 分页查询基类
export interface PagedQueryDto {
  pageIndex: number
  pageSize: number
  keyword?: string
}

// 分页结果
export interface PagedResultDto<T> {
  items: T[]
  totalCount: number
  pageIndex: number
  pageSize: number
  totalPages: number
  total?: number // 兼容性属性
}

// 核心指标DTO
export interface CoreMetricsDto {
  id: number
  date: string
  salesRevenue: number
  salesOrderCount: number
  collection: number
  purchaseExpense: number
  purchaseOrderCount: number
  paidAmount: number
  remarks?: string
}

// 统计数据查询DTO
export interface StatisticsQueryDto {
  startDate?: string
  endDate?: string
  type?: string
  timeRange?: string
}

// 统计数据DTO
export interface StatisticsDto {
  id: number
  date: string
  type: string
  orderAmount: number
  orderCount: number
  timeRange?: string
  remarks?: string
}

// 通知公告查询DTO
export interface AnnouncementQueryDto extends PagedQueryDto {
  type?: string
  isActive?: boolean
}

// 通知公告DTO
export interface AnnouncementDto {
  id: number
  content: string
  type: string
  priority: number
  isActive: boolean
  publishTime?: string
  expiryTime?: string
  publisher?: string
  targetUserGroup?: string
  remarks?: string
  createTime: string
  creator?: string
}

// 采购订单查询DTO
export interface PurchaseOrderQueryDto extends PagedQueryDto {
  status?: string
  orderType?: string
  priority?: string
  amountRange?: string
  createStartTime?: string
  createEndTime?: string
}

// 采购订单DTO
export interface PurchaseOrderDto {
  id: number
  orderNumber: string
  subject: string
  orderType: string
  status: string
  totalAmount: number
  supplierId?: number
  supplierName?: string
  expectedArrivalDate?: string
  remarks?: string
  createTime: string
  creator?: string
  updateTime?: string
  priority?: string
  expectedDeliveryDate?: string
  supplierContact?: string
  supplierPhone?: string
  supplierEmail?: string
  supplierAddress?: string
  salesOrderId?: number
  salesOrderNumber?: string
  requisitionId?: number
  requisitionNumber?: string
  paymentMethod?: string
  paymentTerms?: string
  shippingMethod?: string
  deliveryAddress?: string
  items?: PurchaseOrderItemDto[]
  submitTime?: string
}

// 生产工单查询DTO
export interface ProductionOrderQueryDto extends PagedQueryDto {
  status?: string
  responsiblePerson?: string
}

// 生产工单DTO
export interface ProductionOrderDto {
  id: number
  orderNumber: string
  subject: string
  orderType: string
  productionItem: string
  status: string
  plannedStartTime?: string
  plannedCompletionTime?: string
  plannedIntroTime?: string
  actualStartTime?: string
  actualCompletionTime?: string
  responsiblePerson?: string
  plannedQuantity: number
  totalQuantity?: number
  completedQuantity?: number
  actualQuantity: number
  priority: number
  remarks?: string
  createTime: string
  creator?: string
}

// 销售订单查询DTO
export interface ProductionSalesOrderQueryDto extends PagedQueryDto {
  status?: string
  customerName?: string
}

// 销售订单DTO
export interface ProductionSalesOrderDto {
  id: number
  orderNumber: string
  subject: string
  orderType: string
  status: string
  deliveryDate?: string
  totalAmount: number
  customerId?: number
  customerName?: string
  remarks?: string
  createTime: string
  creator?: string
}

// 审批单据查询DTO
export interface ApprovalDocumentQueryDto extends PagedQueryDto {
  documentType?: string
  status?: string
}

// 审批单据DTO
export interface ApprovalDocumentDto {
  id: number
  documentType: string
  documentId: number
  documentNumber?: string
  status: string
  priority: number
  applicant?: string
  applicationTime?: string
  approver?: string
  approvalTime?: string
  approvalComments?: string
  remarks?: string
  createTime: string
  creator?: string
}

// 仓库查询DTO
export interface WarehouseQueryDto extends PagedQueryDto {
  warehouseType?: string
  status?: string
}

// 仓库DTO
export interface WarehouseDto {
  id: number
  warehouseName: string
  location?: string
  warehouseType?: string
  manager?: string
  contactPhone?: string
  status: string
  remarks?: string
  createTime: string
  creator?: string
}

// 生产物品查询DTO
export interface ProductionItemQueryDto extends PagedQueryDto {
  itemType?: string
  warehouseId?: number
}

// 生产物品DTO
export interface ProductionItemDto {
  id: number
  itemNumber: string
  itemName: string
  batchNumber?: string
  productionDate?: string
  expiryDate?: string
  warehouseId?: number
  warehouseName?: string
  inventoryQuantity: number
  itemType?: string
  specification?: string
  unit?: string
  unitPrice?: number
  standardCost?: number  // 添加缺失的standardCost属性
  remarks?: string
  createTime: string
  creator?: string
}

// 工序查询DTO
export interface ProcessQueryDto extends PagedQueryDto {
  status?: string
  processType?: string
}

// 工序DTO
export interface ProcessDto {
  id: number
  documentNumber: string
  processName: string
  processCode: string  // 添加缺失的processCode属性
  standardTime?: number  // 添加缺失的standardTime属性
  unit?: string  // 添加缺失的unit属性
  status: string
  plannedStartTime?: string
  plannedIntroTime?: string
  actualStartTime?: string
  actualCompletionTime?: string
  responsiblePerson?: string
  processType?: string
  description?: string
  priority: number
  remarks?: string
  createTime: string
  creator?: string
}

// 待审批单据统计
export interface ApprovalCountDto {
  documentType: string
  count: number
  icon: string
  iconClass: string
}

// 图表数据
export interface ChartDataDto {
  // 时间标签（X轴）
  TimeLabels: string[]
  // 订单金额数据（Y轴）
  orderAmounts: number[]
  // 订单数量数据（Y轴）
  orderCounts: number[]
  // 时间范围
  timeRange: string
  // 统计类型（sales/purchase）
  type: string
}

// 审批决策DTO
export interface ApprovalDecisionDto {
  decision: string
  approvalComments?: string
  comments?: string // 兼容性属性
  approverId?: string
  approverName?: string
  approvalMethod?: string
  attachmentUrls?: string[]
}

// 审批流程DTO
export interface ApprovalFlowDto {
  currentStep: number
  purchaseOrderId: number
  currentStatus: string
  currentApprover?: string
  approvalRecords: PurchaseOrderApprovalRecordDto[]
  nextApprover?: string
  canWithdraw: boolean
  canResubmit: boolean
}

// 扩展采购订单DTO
export interface PurchaseOrderExtendedDto extends PurchaseOrderDto {
  relatedSalesOrderId?: number
  relatedSalesOrderNumber?: string
  relatedRequisitionIds?: number[]
  items?: PurchaseOrderItemDto[]
  approvalFlow?: ApprovalFlowDto
  submitterId?: string
  submitTime?: string
  lastModifier?: string
  lastModifyTime?: string
}

// 采购订单物品DTO
export interface PurchaseOrderItemDto {
  id: number
  purchaseOrderId?: number
  materialId?: number
  materialName?: string
  itemCode?: string
  itemName?: string
  specification?: string
  unit: string
  quantity: number
  unitPrice: number
  totalAmount?: number
  amount?: number // 兼容性属性
  requiredDate?: string
  remarks?: string
}

// 采购订单审批记录DTO
export interface PurchaseOrderApprovalRecordDto {
  id: number
  purchaseOrderId: number
  stepSequence: number
  approverId: string
  approverName: string
  approverRole?: string
  decision: string
  approvalComments?: string
  approvalTime: string
  statusBefore: string
  statusAfter: string
  processingDurationMinutes: number
  approvalMethod?: string
  attachmentUrls?: string[]
  ipAddress?: string
  userAgent?: string
  createTime: string
  creator?: string
  // 扩展属性用于历史记录显示
  orderNumber?: string
  orderType?: string
  supplierName?: string
  orderAmount?: number
}

// 扩展采购订单查询DTO
export interface PurchaseOrderExtendedQueryDto extends PurchaseOrderQueryDto {
  creator?: string
  createStartTime?: string
  createEndTime?: string
  minAmount?: number
  maxAmount?: number
  includeApprovalFlow: boolean
}

// 采购订单状态枚举
export enum PurchaseOrderStatus {
  Draft = "未提交",
  PendingApproval = "待审批",
  InApproval = "审批中",
  Approved = "已审批",
  Rejected = "被驳回",
  Withdrawn = "已撤回"
}

// 审批决策枚举
export enum ApprovalDecision {
  Approve = "通过",
  Reject = "驳回",
  Transfer = "转交"
}

// 入库订单查询DTO
export interface InboundOrderQueryDto extends PagedQueryDto {
  status?: string
  warehouseId?: number
}

// 入库订单DTO
export interface InboundOrderDto {
  id: number
  purchaseOrderId: number
  inboundNumber: string
  warehouseId: number
  warehouseName?: string
  inboundDate: string
  quantity: number
  actualQuantity: number
  status: string
  operator?: string
  remarks?: string
  createTime: string
  creator?: string
}

// 发票到票查询DTO
export interface InvoiceArrivalQueryDto extends PagedQueryDto {
  status?: string
  invoiceType?: string
}

// 发票到票DTO
export interface InvoiceArrivalDto {
  id: number
  purchaseOrderId: number
  invoiceNumber: string
  invoiceType: string
  invoiceAmount: number
  invoiceDate: string
  arrivalDate: string
  status: string
  operator?: string
  remarks?: string
  createTime: string
  creator?: string
}

// 费用订单查询DTO
export interface ExpenseOrderQueryDto extends PagedQueryDto {
  status?: string
  paymentMethod?: string
}

// 费用订单DTO
export interface ExpenseOrderDto {
  id: number
  purchaseOrderId: number
  expenseNumber: string
  expenseAmount: number
  paymentMethod: string
  paymentDate: string
  status: string
  operator?: string
  remarks?: string
  createTime: string
  creator?: string
}

// API结果包装类型
export interface ApiResult<T> {
  success?: boolean
  data: T | null
  message?: string
  msg?: string
  code?: number
} 